// main.js
const { app, ipcMain, BrowserWindow } = require('electron')

// window page
const { createStartWindow } = require('../core/window_page/window_start.js')
const { createMainWindow } = require('../core/window_page/window_main.js')
const { createVideoCallWindow } = require('../core/window_page/window_call.js')

app.whenReady().then(() => {
    createStartWindow()
    // createMainWindow()
    // createVideoCallWindow()
})

app.on('ready', () => {
    // 统一窗口控制IPC处理
    ipcMain.handle('window-control-invoke', (event, action) => {
        const win = BrowserWindow.fromWebContents(event.sender)
        if (!win) return

        switch (action) {
            case 'minimize':
                win.minimize()
                break
            case 'maximize':
                win.isMaximized() ? win.unmaximize() : win.maximize()
                break
            case 'close':
                win.close()
                break
            case 'toggle-fullscreen':
                win.setFullScreen(!win.isFullScreen())
                break
        }
    })
})

app.on('window-all-closed', () => {
    app.quit()
})